import { userPage, userAdd, userEdit, userGet } from '@/api/system/user'

const state = {}

const mutations = {}

const actions = {
  // page
  userPage({ commit, state }, params) {
    return new Promise((resolve, reject) => {
      userPage(params)
        .then(data => {
          resolve(data)
        })
        .catch(error => {
          reject(error)
        })
    })
  },
  // add
  userAdd({ commit, state }, params) {
    return new Promise((resolve, reject) => {
      userAdd(params)
        .then(data => {
          resolve(data)
        })
        .catch(error => {
          reject(error)
        })
    })
  },
  // edit
  userEdit({ commit, state }, params) {
    return new Promise((resolve, reject) => {
      userEdit(params)
        .then(data => {
          resolve(data)
        })
        .catch(error => {
          reject(error)
        })
    })
  },
  // get
  userGet({ commit, state }, params) {
    return new Promise((resolve, reject) => {
      userGet(params)
        .then(data => {
          resolve(data)
        })
        .catch(error => {
          reject(error)
        })
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
